#include <iostream>
#include <stdio.h>
#include <unistd.h>
#include "Protocol.h"
#include <vector>
using namespace std;

#define HEAD_0 'S'
#define HEAD_1 'C'
#define LENGTH_BIT 2
#define DATA_BEG 3

Protocol::Protocol()
: m_length_(0)
{
    m_data_.clear();
    m_data_.push_back(HEAD_0);
    m_data_.push_back(HEAD_1);
    m_data_.push_back(0);
}

void Protocol::setBcc()
{
    uint8_t bcc = 0;
    for(uint32_t i = DATA_BEG;  i < m_length_ + DATA_BEG; ++i) {
        bcc ^= m_data_[i];
    }
    m_data_.push_back(bcc);
}

vector<uint8_t> Protocol::getData() {
    return m_data_;
}

void Protocol::setData(char* data, size_t length)
{
    m_data_.resize(3);
    m_length_=length;
    Uint32ToUint8 dataRes;
    dataRes.
    m_data_[LENGTH_BIT] = m_length_;
    for(int i = 0; i < m_length_; ++i) {
        m_data_.push_back(data[i]);
    }
    setBcc();
}

vector<uint8_t> Protocol::praseData(char*buf, size_t len) {

}